//
//  ConditionTableViewController.m
//  GraduationProject;
//
//  Created by 伍宏伟 on 16/4/12.
//  Copyright © 2016年 伍宏伟. All rights reserved.
//

#import "ConditionTableViewController.h"
#import "Request.h"
#import "Con_1_TableViewCell.h"
#import "Con_2_TableViewCell.h"
#import "AFRequestJSON.h"
@interface ConditionTableViewController ()<AFRequestJSONDelegate>
{
    
    NSString *_Str;
    
}

@end

@implementation ConditionTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
    
//    Request *rq = [Request new];
//    
//    
//    [rq requestWithCityName:@"beijing" delegate:self];
//    
//    
//    
//    
//    _Str = rq.responseResult;
//    
//    NSLog(@"%@",_Str);
    
    //[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cells"];
    self.edgesForExtendedLayout = UIRectEdgeNone;
    
    self.tabBarItem.image = [UIImage imageNamed:@"condition_1.png"];
    self.tabBarItem.selectedImage = [UIImage imageNamed:@"condition_2.png"];
    


    UIImageView *backGroundView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"theme_1_1.jpg"]];
    
    backGroundView.frame = self.view.frame;
    
    NSLog(@"%f",backGroundView.frame.size.width);
    
    backGroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    
    [self.tableView setBackgroundView:backGroundView];
    
    self.tableView.estimatedRowHeight = 68.0;
    
    self.tableView.rowHeight = UITableViewAutomaticDimension;
    
    
    //self.tableView.backgroundColor = [UIColor clearColor];
    
    
    /*
    AFRequestJSON *model = [[AFRequestJSON alloc]init];
    
    [model RequestCityByImportCityId:@"beijing"];
    */
    AFRequestJSON *model = [AFRequestJSON Delegate:self RequestCityWithId:@"beijing"];
    
    
    
}

-(void)CityJSONSuccessReturn:(NSDictionary *)JSONDictionary
{
    NSLog(@"JSONDictionary:%@",JSONDictionary);
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return 5;
}

//-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    
//    return 30;
//}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (indexPath.row == 0) {
        
        Con_1_TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cells" forIndexPath:indexPath];
        cell.backgroundColor = [UIColor clearColor];
        //cell.userInteractionEnabled = NO;
        return cell;
    }
    
    else {
        
    
        Con_2_TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellss" forIndexPath:indexPath];
        cell.backgroundColor = [UIColor clearColor];
        //cell.userInteractionEnabled = NO;
        if (indexPath.row == 1) {
            cell.aLabel.text = @"湿度湿度湿度湿度湿度湿度湿度湿度湿度湿度湿度湿度湿度湿度湿度湿度湿度湿度湿度";
            cell.dataLabel.text = @"43%";
            
        }
        else if(indexPath.row == 2)
        {
            cell.aLabel.text = @"气压";
            cell.dataLabel.text = @"1003";
        }
        else if(indexPath.row == 3)
        {
            cell.aLabel.text = @"能见度";
            cell.dataLabel.text = @"10km";
        }
        else
        {
            cell.aLabel.text = @"风力风向";
            cell.dataLabel.text = @"3级北风15kmph";
        }
       
        return cell;
    }
    
    
    
    
    
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    UILabel *label = [cell.contentView viewWithTag:100];
    
    [label sizeToFit];
    
    [tableView beginUpdates];
    if (label.numberOfLines == 0) {
        label.numberOfLines = 1;
    }
    else
    {
        label.numberOfLines = 0;
    }
    NSLog(@"%ld",indexPath.row);
    
    [tableView endUpdates];
    
}



/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
